﻿@model SPagedList<Dyd.BaseService.ServiceCenter.Domain.Model.tb_client>
@{
    ViewBag.Title = "tb_client";
    Layout = "~/Views/Shared/_LayoutLayer.cshtml";
}
@Html.AntiForgeryToken()
<div class="main_content">
    <div class="main">
        @using (Ajax.BeginForm("ClientIndex", "Client", null, new AjaxOptions { UpdateTargetId = "ajaxList", InsertionMode = InsertionMode.Replace }, new { id = "ajaxForm" }))
        {
            <input id="serverid" name="serverid" type="hidden" value="@ViewBag.ServerId" />
            @*<div class="pt10">
                <span>每页显示：</span><input value="@ViewBag.PageSize" type="text" name="pageSize" id="pageSize" style="width:50px;" maxlength="4" />
            </div>*@
        }
    </div>

    <div id="ajaxList" class="m10">
        @Html.Partial("_ClientIndex", Model)
    </div>
</div>
@section Scripts{
    <script src="~/Scripts/layer/layer.js"></script>
    <link href="~/Scripts/layer/skin/layer.css" rel="stylesheet" />
}

@section footerScripts{
    @Html.SPagerScript()
    <script>

        $(function () {

            $("#ajaxList").on("click", function (event) {
                var type = $(event.target).attr("class");
                switch (type) {   
                    case "deleteItem": deleteItem(event.target); break;
                }
            });
        });

        //删除
        function deleteItem(obj) {
            var id = $(obj).parent().parent().attr("data-id");
            if (confirm("确认删除")) {
                $.ajax({
                    url: "/Client/ClientDelete",
                    type: "post",
                    data: antiToken({ id: id }),
                    dataType: "json",
                    success: function (data) {
                        if (data.Flag) {
                            alert(data.Message);
                            window.location.reload();
                        } else {
                            alert(data.Message);
                        }
                    }
                });
            }
        }
    </script>
}
